<!-- <template>
    <BlogPreviewComponent v-for="(item, index) in blogPreviewList" :key="item.id" :blogPreview="item">
    </BlogPreviewComponent>
</template>

<script setup lang="ts">
import BlogPreviewComponent from '@/components/blog/BlogPreviewComponent.vue';
import { BlogPreview } from '@/types/blogType';
import { tokenAxios } from '@/utils/tokenAxiosUtils';
import { onMounted, ref, watch } from 'vue';

const props = defineProps({
    index: Number
})

const blogPreviewList = ref<BlogPreview[]>();

const fetchArticle = async (index: number) => {
    try {
        const res = await tokenAxios.get(`/blog/getPreview/${index}`);
        blogPreviewList.value = res.data as BlogPreview[];
    }
    catch (error) {
        console.error("获取博客数据失败", error)
    }
}

onMounted(() => {
    fetchArticle(props.index);
})

watch(() => props.index, (newIndex) => {
    console.log('ID变化:', props.index, newIndex)
    fetchArticle(newIndex)
})
</script> -->